cmake_minimum_required(VERSION 3.8)
project(arm_control)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(message_filters REQUIRED)
find_package(serial REQUIRED)
find_package(Eigen3 REQUIRED)

add_executable(arm_joint src/arm_joint.cpp)
add_executable(arm_adc   src/arm_adc.cpp)
add_executable(arm_encoder  src/arm_encoder.cpp)
add_executable(arm_bigvalves src/arm_bigvalves.cpp)
add_executable(arm_endeffector src/arm_endeffector.cpp)
add_executable(arm_kinematic    src/arm_kinematic.cpp)
add_executable(arm_kinematic_v2 src/arm_kinematic_v2.cpp)
add_executable(arm_constyle src/arm_constyle.cpp)



add_executable(nazzle_valves src/nazzle_valves.cpp)

add_executable(topicrelay   src/topicrelay.cpp)

add_executable(test_1         src/test_1.cpp)
add_executable(test_2         src/test_2.cpp)
add_executable(test_3         src/test_3.cpp)
add_executable(test_poc       src/test_poc.cpp)


add_executable(control_valves  src/control_valves.cpp)





target_include_directories(arm_joint PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/arm_control>
  $<INSTALL_INTERFACE:include>)
target_include_directories(arm_encoder PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/arm_control>
  $<INSTALL_INTERFACE:include>)
target_include_directories(nazzle_valves PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/arm_control>
  $<INSTALL_INTERFACE:include>)


include_directories(${EIGEN3_INCLUDE_DIR})
target_compile_features(arm_joint PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17

ament_target_dependencies(
  arm_joint
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  arm_adc
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  arm_encoder
  "rclcpp"
  "std_msgs"
  "message_filters"
  "serial"
)

ament_target_dependencies(
  test_1
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  test_2
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  test_3
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  test_poc
  "rclcpp"
  "std_msgs"
)




ament_target_dependencies(
  arm_kinematic
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_kinematic_v2
  "rclcpp"
  "std_msgs"
)



ament_target_dependencies(
  arm_constyle
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  nazzle_valves
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_endeffector
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  arm_bigvalves
  "rclcpp"
  "std_msgs"
  "serial"
)

ament_target_dependencies(
  topicrelay
  "rclcpp"
  "std_msgs"
)

ament_target_dependencies(
  control_valves
  "rclcpp"
  "std_msgs"
)

target_link_libraries(arm_joint ${CONTROLCAN} controlcan)
target_link_libraries(arm_encoder ${CONTROLCAN} controlcan)
target_link_libraries(nazzle_valves ${CONTROLCAN} controlcan)


install(TARGETS 
  arm_joint
  arm_adc
  arm_encoder
  arm_kinematic_v2
  arm_constyle

  test_1
  test_2
  test_3
  test_poc
  control_valves
  
  arm_kinematic
  nazzle_valves
  arm_bigvalves
  arm_endeffector
  topicrelay
  DESTINATION lib/${PROJECT_NAME})


install(DIRECTORY 
  launch
  DESTINATION share/${PROJECT_NAME}/
)


if(BUILD_test_1ING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_1_dependencies()
endif()

ament_package()
